<%
    Users user = Trader.getUser(request.getParameter("uid"));
	wstrader.task.traffic.physical.Contract task = user.traffic.physical.contract;

	if (!user.Authenticated()) {
		response.sendRedirect("logon.jsp");
		return;
	}
	((Tasks)task.getOwner()).clearFocus();
	task.setFocus(true);	
	Trader.window_width = "90%";

%>

<%@include file="../header.jsp"%>

<%
	
	ResultSet rs=null;
	long focused_id = task.doTask();	
	Record ref = task.getRecord("contracts",focused_id);
	String CntType = ref.getString("type");
	//Record rcDI = new Record(task.getDeliveryInstruction_record());
	//Record rcSI = new Record(task.getShippingInstruction_record());
%>
<link href="style.css" rel="stylesheet" type="text/css">

<script language="javascript">

function doListView()
{
	var form = document.formMain;
	form.action = "traffic.physical.jsp";
	form.submit();
}

function new_ImportDetails(i)
{
		var form = document.formMain;
		var ImpTon = parseFloat(form.ImpTon.value);
		var Tons = parseFloat(form.tons.value);
		if ((Tons-ImpTon) > 1)
		{
			show("wn_" + i);
			setValue("ref_number_" + i,"New Number");//
			setValue("wn_date_" + i, getNewDate());
			setValue("wn_time_" + i, getNewTime());
			highlightOn(getObj("wn_" + i),1);
		}
		else
		{
			alert("No More Balance Quantity To Be Received");
		}
}	


function new_exporttDetails(i)
{
	var form = document.formMain;
	var ExpTon = parseFloat(form.ExpTon.value);
	var Tons = parseFloat(form.tons.value);
	if ((Tons-ExpTon) > 1)
	{
		show("al_" + i);
		setValue("alc_ref_number_" + i,"New Number");//
		highlightOn(getObj("wn_" + i),1);
	}
	else
	{
		alert("No More Balance Quantity To Be Shipped");
	}
}

function doUpdateWNI()
{
    var form = document.formMain;
  	doTask(4);
}  

function doUpdateAlc()
{
    var form = document.formMain;
  	doTask(3);
} 

function setRowSel(id)
{
	var form= document.formMain;
	highlightOn(id,2);
	var rowsel = getObj(id);
	form.sel_row.value = (id.id).substring(3);
}

function setRowSel_Alc(id)
{
	var form= document.formMain;
	highlightOn(id,2);
	var rowsel = getObj(id);
	form.sel_row_alc.value = (id.id).substring(3);
}

function ajaxChkRefNo( page,id )
{
	var form= document.formMain;
	page = page + "?refno="+ form.uid.value + "|" + getValue(id.id);
	var xmlHttp;
	try
  	{  // Firefox, Opera 8.0+, Safari  
  		xmlHttp=new XMLHttpRequest();  }
		catch (e)
  		{  // Internet Explorer  
  		try
    	{    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    }
  			catch (e)
    		{    try
      		{      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      }
    catch (e)
      {      alert("Your browser does not support AJAX!");      return false;      }    }  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      	document.getElementById("AjaxRefChk").innerHTML=xmlHttp.responseText;
		if(form.chkbalton.value==0)
		{
			setValue(id.id,"");
			setFocus(id.id);
			alert("The selected contract is fully allocated");
		}
		else
		{
			var rowsel=(id.id).substring(15);
			var balexp = parseFloat(form.tons.value) - parseFloat(form.ExpTon.value);
			if (balexp < parseFloat(form.chkbalton.value))
			{
				setValue("allocated_tons_"+rowsel,balexp);
			}
			else
			{
				setValue("allocated_tons_"+rowsel,form.chkbalton.value);
			}
		}
      }
    }
  xmlHttp.open("GET",page,true);
  xmlHttp.send(null);  
 }
 
 function chkExpTon(id)
 {
 	var form= document.formMain;
	var balexp = parseFloat(form.tons.value) - parseFloat(form.ExpTon.value);
	var rowsel=(id.id).substring(15);
	if (getValue(id.id) > balexp)
	{
		alert("Quantity Entered Is More Than The Balance Quantity To Export");
		setValue("allocated_tons_"+rowsel,balexp);
	}
	else
	{
		
	}
 }
 
 function chkComp(i)
 {
 	//alert(i);
	var form = document.formMain;
 	if (i=='E')
	{
		//alert(form.comp_exp_.value);
		doTask(5);
	}
	else
	{
		//alert(form.comp_imp_.value);
		doTask(6);
	}
 }

</script>
<style type="text/css">
<!--
.style3 {font-weight: bold}
-->
</style>
<form method="POST" name="formMain" action="" onSubmit="">				  
	<table width="100%"  border="0" cellpadding="0" cellspacing="0" class="style2">
		<tr>
			<td colspan="2"><img src="images/contracts.jpg" width="250" height="30"></td>
		</tr>
          <tr bgcolor="#EEEEEE" class="style3" align="center" style="font-weight:bold">
            <td width="14%">Contracts</td>
            <td width="86%" align="left"><label id="e16">Details</label></td>
          </tr>
          <tr>
            <td valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0" class="style2">
  <tr>
    <td><select name="contracts" size=19 class="style11" id="contracts" style="width:100%;" onChange="doPost();">
                    <%@include file="include/ContractRefNoList.jsp"%>
            </select></td>
  </tr>
  <tr>
    <td>&nbsp;
	</td>
  </tr>
</table>
</td>
            <td valign="top"><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="style2">
              <tr>
                <td><table width="100%"  border="1" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="270"><table width="100%"  border="0" cellpadding="1" cellspacing="1" class="style2">
                      <tr>
                        <td width="45%"><table width="100%"  border="0" cellpadding="1" cellspacing="0" class="style2">
                          <tr>
                            <td width="35%" align="right">Contract Ref &nbsp;</td>
                            <td colspan="3"><strong><%=ref.getString("ref_number")%></strong></td>
                          </tr>
<%
	String type ="";
	if (ref.getString("type").compareTo("P")==0) type ="Purchase Contract";
	if (ref.getString("type").compareTo("S")==0) type ="Sales Contract";	
%>						  
                          <tr>
                            <td align="right">Contract Type &nbsp;</td>
                            <td colspan="3"><input type="text" name="contract_type" id="contract_type" class="style2" style="width:50%;" value="<%=type%>" readonly="true"></td>
                          </tr>
                          <tr>
                            <td align="right">Contract No </td>
                            <td colspan="3"><p>
                              <input type="text" name="contract_no" id="contract_no" class="style2" style="width:50%;" value="<%=ref.getString("contract_no")%>" readonly="true">
                            </p>                              </td>
                          </tr>
				  
                          <tr>
                            <td align="right">Supplier/Buyer &nbsp;</td>
                            <td colspan="3"><input type="text" name="supplier_buyer_id" id="supplier_buyer_id" class="style2" style="width:50%;" value="<%=task.getFieldValueForId("company_master","name",ref.getIntValue("supplier_buyer_id"))%>" readonly="true"></td>
                          </tr>

                          <tr>
                            <td align="right">Supplier/Buyer Ref &nbsp;</td>
                            <td colspan="3"><input type="text" name="supplier_buyer_ref" id="supplier_buyer_ref" class="style2" style="width:50%;" value="<%=ref.getString("supplier_buyer_ref")%>" readonly="true"></td>
                          </tr>
                          <tr>
                            <td align="right">Packing &nbsp;</td>
                            <td colspan="3"><input type="text" name="packing_id" id="packing_id" class="style2" style="width:50%;" value="<%=task.getFieldValueForId("packing_master","name",ref.getIntValue("packing_id"))%>" readonly="true"></td>
                          </tr>
                          <tr>
                            <td align="right">Quantity &nbsp;</td>
                            <td colspan="3"><input type="text" name="tons" id="tons" class="style2" style="width:80px; text-align:right" value="<%=ref.getFloatValue("tons")%>" onChange="tonsChanged();" readonly="true">&nbsp;Mts </td>
                          </tr>
                          <tr>
                            <td align="right">Kg per Bag &nbsp;</td>
                            <td colspan="3"><input type="text" name="kg_per_bag" id="kg_per_bag" class="style2" style="width:80px; text-align:right" value="<%=ref.getFloatValue("kg_per_bag")%>" onChange="tonsChanged()" readonly="true"></td>
                          </tr>
                          <tr>
                            <td align="right">No of Bags &nbsp;</td>
                            <td colspan="3"><input type="text" name="no_of_bags" id="no_of_bags" class="style2" style="width:80px; text-align:right" value="<%=ref.getInt("no_of_bags")%>" readonly="true"></td>
                          </tr>
                          <tr>
                          	<% 
								float chktons = task.getSum("tons","contract_id","delivery_instruction", focused_id);
								float chktons_si = task.getSum("tons","contract_id","shipping_instruction", focused_id);
							%>
                            <td align="right"><input name="chk_tons_si" type="hidden" id="chk_tons_si" value="<%=chktons_si%>" />
                              <input name="chk_tons" type="hidden" id="chk_tons" value="<%=chktons%>" /></td>
                            <td colspan="3">&nbsp;</td>
                          </tr>
                          <tr>
                            <td align="right">&nbsp;</td>
                            <td width="7%">&nbsp;</td>
								<td width="29%">&nbsp;</td>
							  <td width="29%">&nbsp;</td>
								<input type="hidden" name="completed"  id="completed"  value="<%=ref.getIntValue("status")%>">
                          </tr>
                        </table></td>
                        <td valign="top"><table width="100%"  border="0" cellpadding="1" cellspacing="0" class="style2">
                          <tr>
                            <td width="30%" align="right">Origin &nbsp;</td>
                            <td><input type="text" name="origin_id" id="origin_id" class="style2" style="width:50%;" value="<%=task.getFieldValueForId("origin_master","name",ref.getIntValue("origin_id"))%>" readonly="true"></td>
                          </tr>
                          <tr>
                            <td align="right">Quality &nbsp;</td>
                            <td><input type="text" name="quality_id" id="quality_id" class="style2" style="width:50%;" value="<%=task.getFieldValueForId("quality_master","name",ref.getIntValue("quality_id"))%>" readonly="true">
                              <input name="quality" type="hidden" id="quality" value="<%=ref.getIntValue("quality_id")%>" /></td>
                          </tr>
                          <tr>
                            <td align="right">Grade &nbsp;</td>
                            <td><input type="text" name="grade_id" id="grade_id" class="style2" style="width:50%;" value="<%=task.getFieldValueForId("grade_master","name",ref.getIntValue("grade_id"))%>" readonly="true">
                              <input name="grade" type="hidden" id="grade" value="<%=ref.getIntValue("grade_id")%>" /></td>
                          </tr>
                          <tr>
                            <td align="right">&nbsp;</td>
                            <td>&nbsp;</td>
                          </tr>
						  
                          <tr>
                            <td align="right">Delivery Period &nbsp;</td>
                            <td><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="style2">
                              <tr>
                                <td width="27%">From</td>
                                <td width="26%">&nbsp;</td>
                                <td width="27%">To</td>
                                <td width="20%">&nbsp;</td>
                              </tr>
                              <tr>
                                <td><input type="text" name="first_date" id="first_date" class="style2" style="width:70px; text-align:center" value="<%=ref.getDate("first_date")%>" readonly="true"></td>
                                <td><a  onclick="popUpCalendar(this,'first_date','dd-mmm-yy');"><IMG width="19" height="19" border="0" src="js/calendar.gif" title="dd-MMM-yy (example: 01-Jan-04)"></a></td>
                                <td><input type="text" name="last_date" id="last_date" class="style2" style="width:70px; text-align:center" value="<%=ref.getDate("last_date")%>" readonly="true"></td>
                                <td><a onclick="popUpCalendar(this,'last_date','dd-mmm-yy');"><IMG width="20" height="20" border="0" src="js/calendar.gif" title="dd-MMM-yy (example: 01-Jan-04)"></a></td>
                              </tr>
                            </table></td>
                          </tr>
                          <tr>
                            <td align="right">Remarks &nbsp;</td>
                            <td><textarea name="remarks" id="remarks" rows="4" class="style2" style="width:100%" readonly><%=ref.getString("remarks")%></textarea></td>
                          </tr>
                          
                          <tr>
                            <td align="right">Imported Tons</td>
                            <td id=""><span class="style3"><input name="ImpTon" type="text" class="textnoedit" id="ImpTon" style="width:60px" value="" readonly="true" /></span></td>
                          </tr>
                          <tr>
                            <td align="right">Exported Tons</td>
                            <td id=""><span class="style3">
                              <input name="ExpTon" type="text" class="textnoedit" id="ExpTon" style="width:60px" value="" readonly="true" />
                            </span></td>
                          </tr>
                          <tr>
                            <td align="right">Pending Tons</td>
                            <td id=""><span class="style3">
                              <input name="TBR" type="text" class="textnoedit" id="TBR" style="width:60px" value="" readonly="true" />
                            </span></td>
                          </tr>
                        </table></td>
                      </tr>
                    </table></td>
                  </tr>
                </table></td>
              </tr>
			  <tr>
			    <td>
			      <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td height="24">&nbsp;</td>
                      <td align="right"><img src="../shared/images/listview.jpg" width="55" height="18" onClick="doListView();"></td>
                    </tr>
                  </table></td>
		      </tr>
			  <tr>
			    <td><table width="100%"  border="1" cellspacing="0" cellpadding="0">
                  <tr>
                  <!---- IF CONTRACT TYPE IS 'P' ------------->
                    <td>
                    <%
						int no = 1;
						float total_net_weight   = 0;
						int total_no_of_bags = 0;					
						if (CntType.compareTo("P")==0)
						{
					%>
                    <span class="style3">
                    </span>
                    <table width="100%"  border="0" cellpadding="0" cellspacing="0" class="style2">	
                    			  
                      <tr>
                        <td align="center" height="24"><div align="left"><strong>&nbsp;Import Details
                          
                        </strong>
                            <input name="sel_row" type="hidden" id="sel_row" value="0" />
                        </div></td>
                      </tr>
                      <tr>
                        <td><table width="100%"  border="0" cellpadding="1" cellspacing="1" class="style2">
                          <tr bgcolor="#EEEEEE" style="font-weight:bold" align="center">
                            <td width="4%">No</td>
                            <td width="21%" colspan="2">IM Ref</td>
                            <td width="21%">IM Date</td>
                            <td width="14%">Location</td>
                            <td width="8%">Tons<br />
                              (Mts)</td>
                            <td width="7%">Bags</td>
                            <td width="2%">Del</td>
                            <td width="3%">Sav</td>
                          </tr>
                          <%
	Record rc = new Record(task.fetchImportList());
	rc.beforeFirst();

	while (rc.next()) 
	{
		System.out.println("Container Loop");
		total_net_weight   += rc.getFloatValue("net_weight");
		total_no_of_bags   += rc.getIntValue("no_of_bags");
%>
                          <input type="hidden" name="wn_id_<%=no%>"  id="wn_id_<%=no%>"  value="<%=rc.getInt("id")%>" />
                          <tr id="wn_<%=no%>" onclick="setRowSel(this);">
                            <td bgcolor="#EEEEEE" align="center"><%=no%></td>
                            <td colspan="2" align="center"><input type="text" name="ref_number_<%=no%>"      id="ref_number_<%=no%>" class="style2" style="width:100%;" value="<%=rc.getString("ref_number")%>" /></td>
                            <td align="center"><div align="left">
                              <input type="text" name="date_<%=no%>"    id="date_<%=no%>" class="style2" style="width:90%;" value="<%=rc.getDate("date")%>" />
                              <a onclick="popUpCalendar(this,'date_<%=no%>','dd-mmm-yy');"><img width="20" height="20" border="0" src="js/calendar.gif" title="dd-MMM-yy (example: 01-Jan-04)" /></a></div></td>
                            <td align="center"><input type="text" name="location_<%=no%>"         id="location_<%=no%>" class="style2" style="width:100%;" value="<%=rc.getString("location")%>" /></td>
                            <td align="center"><input type="text" name="net_weight_<%=no%>"   id="net_weight_<%=no%>"   class="style2" style="width:100%; text-align:right" value="<%=rc.getFloat("net_weight",1)%>"   onchange="" /></td>
                            <td align="center"><input type="text" name="no_of_bags_<%=no%>"   id="no_of_bags_<%=no%>"   class="style2" style="width:100%; text-align:right" value="<%=rc.getInt("no_of_bags")%>"       onchange="" /></td>
                            <td align="center"><img src="../shared/images/delete.gif" width="15" height="15" onclick="" /></td>
                            <td align="center"><img src="../shared/images/update.jpg" width="15" height="15" onclick="doUpdateWNI()" /></td>
                          </tr>
                          <%
		no++;
	}
	no=0;
%>
                          <input type="hidden" name="wn_id_<%=no%>"  id="wn_id_<%=no%>"  value="-1" />
                          <tr id="wn_<%=no%>" onclick="highlightOn(this,1);" style="display:none">
                            <td bgcolor="#EEEEEE" align="center"><strong><%=no%></strong></td>
                            <td colspan="2" align="center"><input type="text" name="ref_number_<%=no%>"      id="ref_number_<%=no%>" class="style2" style="width:100%;" value="" /></td>
                            <td align="center"><div align="left">
                              <input type="text" name="date_<%=no%>"    id="date_<%=no%>" class="style2" style="width:90%;" value="" />
                              <a onclick="popUpCalendar(this,'date_<%=no%>','dd-mmm-yy');"><img width="20" height="20" border="0" src="js/calendar.gif" title="dd-MMM-yy (example: 01-Jan-04)" /></a></div></td>
                            <td align="center"><input type="text" name="location_<%=no%>"         id="location_<%=no%>" class="style2" style="width:100%;" value="" /></td>
                            <td align="center"><input type="text" name="net_weight_<%=no%>"   id="net_weight_<%=no%>"   class="style2" style="width:100%; text-align:right" value=""   onchange="" /></td>
                            <td align="center"><input type="text" name="no_of_bags_<%=no%>"   id="no_of_bags_<%=no%>"   class="style2" style="width:100%; text-align:right" value=""       onchange="" /></td>                            
                            <td align="center"><img src="../shared/images/delete.gif" width="15" height="15" onclick="" /></td>
                            <td align="center"><img src="../shared/images/update.jpg" width="15" height="15" onclick="doUpdateWNI()" /></td>
                          </tr>
                          <tr>
                            <td><img src="../shared/images/new.gif" width="15" height="15" title="Input New Weight Certificate" onclick="new_ImportDetails(<%=no%>)" /></td>
                            <td><strong>Complete Import </strong></td>
                            <td><input name="comp_imp_" type="checkbox" id="comp_imp_" value="1" onclick="chkComp('I')" />
                              <input type="hidden"    name="comp_imp"  id="comp_imp"  value="0" /></td>
                            <td>&nbsp;</td>
                            <td align="right"><strong>Total</strong></td>
                            <td align="right"><strong>
                              <label id="wn_net_weight_"><%=Utils.numberToStr(total_net_weight,1)%></label>
                            </strong></td>
                            <td align="right"><strong>
                              <label id="wn_no_of_bags_"><%=total_no_of_bags%></label>
                            </strong></td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                          </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td><div style="overflow:scroll; height:150px;"></div></td>
                      </tr>
<tr>
  <td>&nbsp;</td>
</tr>					  
                    </table>
                    <%
						}
					%>
                    </td>
                    <!---- IF CONTRACT TYPE IS 'P' ------------->
                  </tr>
                  <tr>
                    <td><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="style2">
                      <tr>
                        <td height="24" align="center"><div align="left"><strong>&nbsp;Export Details 
                          
                        </strong>
                            <input name="sel_row_alc" type="hidden" id="sel_row_alc" value="0" />
                        </div></td>
                      </tr>
                      <tr>
                        <td><table width="100%"  border="0" cellpadding="1" cellspacing="1" class="style2">
                          <tr bgcolor="#EEEEEE" style="font-weight:bold" align="center">
                            <td width="4%">No</td>
                            <td colspan="2">Contract Ref</td>
                            <td width="21%">EX Date</td>
                            <td width="14%">Destination</td>
                            <td width="11%">Tons<br />
                              (Mts)</td>
                            <td width="11%">Bags</td>
                            <td width="2%">Del</td>
                            <td width="3%">Sav</td>
                          </tr>
 <%
	Record rcE = new Record(task.fetchTraffic_Cnt_AllocationList(CntType));
	rcE.beforeFirst();
	no = 1;
	float total_net_weight_alc   = 0;
	int total_no_of_bags_alc = 0;
	int SelCntid=0;
	

	while (rcE.next()) 
	{
	
			if (CntType.compareTo("S")==0)
			{	
				SelCntid = rcE.getIntValue("contract_pid");
			}
			else
			{
				SelCntid = rcE.getIntValue("contract_sid");
			}
	
	
		System.out.println("Allocation Loop");
		total_net_weight_alc   += rcE.getFloatValue("allocated_tons");
		total_no_of_bags_alc   += rcE.getIntValue("allocated_bags");
%>
                          <input type="hidden" name="alc_id_<%=no%>"  id="alc_id_<%=no%>"  value="<%=rcE.getInt("id")%>" />
                          <tr id="al_<%=no%>" onclick="setRowSel_Alc(this);">
                            <td bgcolor="#EEEEEE" align="center"><%=no%></td>
                            <td colspan="2" align="center"><input type="text" name="alc_ref_number_<%=no%>"      id="alc_ref_number_<%=no%>" class="style2" style="width:100%;" value="<%=task.getFieldValueForId("contracts","ref_number",SelCntid)%>" onchange="ajaxChkRefNo('traffic.physical.contract.refchk.jsp',this)"/></td>
                            <td align="center"><div align="left">
                              <input type="text" name="alc_date_<%=no%>"    id="alc_date_<%=no%>" class="style" style="width:90%;" value="<%=rcE.getDate("export_date")%>" />
                              <a onclick="popUpCalendar(this,'alc_date_<%=no%>','dd-mmm-yy');"><img width="20" height="20" border="0" src="js/calendar.gif" title="dd-MMM-yy (example: 01-Jan-04)" /></a></div></td>
                            <td align="center"><input type="text" name="alc_location_<%=no%>"         id="alc_location_<%=no%>" class="style2" style="width:100%;" value="<%=rcE.getString("location")%>" /></td>
                            <td align="center"><input type="text" name="allocated_tons_<%=no%>"   id="allocated_tons_<%=no%>"   class="style2" style="width:100%; text-align:right" value="<%=rcE.getFloat("allocated_tons",1)%>"   onchange="chkExpTon(this)" /></td>
                            <td align="center"><input type="text" name="allocated_bags_<%=no%>"   id="allocated_bags_<%=no%>"   class="style2" style="width:100%; text-align:right" value="<%=rcE.getInt("allocated_bags")%>"       onchange="" /></td>
                           <% if (CntType.compareTo("S")==0)
                            {%>
                            <td align="center"><img src="../shared/images/delete.gif" width="15" height="15" onclick="" /></td>
                            <td align="center"><img src="../shared/images/update.jpg" width="15" height="15" onclick="doUpdateAlc()" /></td>
                           <% }
                            else
                            {%>
                            <td width="7%" align="center"></td>
                            <td width="7%" align="center"></td>                            
                            <%}%>
                          </tr>
                          <%
		no++;
	}
	no=0;
%>
                          <input type="hidden" name="alc_id_<%=no%>"  id="alc_id_<%=no%>"  value="-1" />
                          <tr id="al_<%=no%>" onclick="highlightOn(this,1);" style="display:none">
                            <td bgcolor="#EEEEEE" align="center"><strong><%=no%></strong></td>
                            <td colspan="2" align="center"> <select name="alc_ref_number_<%=no%>" id="alc_ref_number_<%=no%>" style="font-family:Arial; font-size:12; width:100%;" tabindex="13" onchange="ajaxChkRefNo('traffic.physical.contract.refchk.jsp',this)">
                      		<%
								task.getResponse().setOption(task.getContractNoList());
								task.getResponse().setSelected("ref_number");
						%>
                    </select></td>
                            <td align="center"><div align="left">
                              <input type="text" name="alc_date_<%=no%>"    id="alc_date_<%=no%>" class="style2" style="width:90%;" value="" />
                              <a onclick="popUpCalendar(this,'alc_date_<%=no%>','dd-mmm-yy');"><img width="20" height="20" border="0" src="js/calendar.gif" title="dd-MMM-yy (example: 01-Jan-04)" /></a></div></td>
                            <td align="center"><input type="text" name="alc_location_<%=no%>"         id="alc_location_<%=no%>" class="style2" style="width:100%;" value="" /></td>
                            <td align="center"><input type="text" name="allocated_tons_<%=no%>"   id="allocated_tons_<%=no%>"   class="style2" style="width:100%; text-align:right" value=""   onchange="chkExpTon(this)" /></td>
                            <td align="center"><input type="text" name="allocated_bags_<%=no%>"   id="allocated_bags_<%=no%>"   class="style2" style="width:100%; text-align:right" value=""       onchange="" /></td>
                            <td align="center"><img src="../shared/images/delete.gif" width="15" height="15" onclick="" /></td>
                            <td align="center"><img src="../shared/images/update.jpg" width="15" height="15" onclick="doUpdateAlc()" /></td>
                          </tr>
                          <tr>
                            <% if (CntType.compareTo("S")==0)
                            {%>
                            <td><img src="../shared/images/new.gif" width="15" height="15" title="Input Export Details" onclick="new_exporttDetails(<%=no%>)" /></td>
                            <td width="18%"><strong>Complete Export</strong></td>
                            <td width="2%"><input name="comp_exp_" type="checkbox" id="comp_exp_" value="1" onclick="chkComp('E')" />
                              <input type="hidden"    name="comp_exp"  id="comp_exp"  value="0" /></td>                            <%
							}
							else
							{
							%>

                            <%
							}
							%>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td align="right"><strong>Total</strong></td>
                            <td align="right"><strong>
                              <label id="wn_net_weight_"><%=Utils.numberToStr(total_net_weight_alc,1)%></label>
                            </strong></td>
                            <td align="right"><strong>
                              <label id="wn_no_of_bags_"><%=total_no_of_bags_alc%></label>
                            </strong></td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                          </tr>
                        </table></td>
                      </tr>
                      <tr>
                        <td><div style="overflow:scroll; height:150px;"></div></td>
                      </tr>
<tr>
	<td id="AjaxRefChk">&nbsp;</td>
</tr>					  
                    </table></td>
                  </tr>
                </table></td>
		      </tr>
            </table>
</td>
          </tr>
		  		  
  </table>
	<input type="hidden" name="uid"  id="uid"  value="<%=user.getuid()%>">
	<input type="hidden" name="task_id"  id="task_id"  value="0">
	<input type="hidden" name="view" id="view" value="<%=task.getRequest().getIntValue("view")%>">	
	<input name="new_rec" type="hidden" id="new_rec" value="0">
    <script>
		var form= document.formMain;
		form.ImpTon.value = <%=Utils.numberToStr(total_net_weight,1)%>;
		form.ExpTon.value = <%=Utils.numberToStr(total_net_weight_alc,1)%>;
		form.TBR.value =<%=Utils.numberToStr(ref.getFloatValue("tons")-total_net_weight_alc,1)%>
	</script>
    
    <script language="javascript">
         setCbx(getObj("comp_imp_"),     <%=ref.getInt("comp_imp")%>);
		 setCbx(getObj("comp_exp_"),     <%=ref.getInt("comp_exp")%>);
	</script>

</form>

<%@include file="../footer.jsp"%>